<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/


get_config_keytable("file_edit");
empty($do) && $do = 'list';
if ($do == 'edit') {
	$id = getGP('id','G','int');
	$blog = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."file  WHERE id = '$id'");
	include_once('template/edit.php');

} elseif ($do == 'save') {
	$savetype = getGP('savetype','P');
	$id = getGP('id','P','int');
	$filetype = getGP('filetype','P');
	$filenumber=getGP('filenumber','P');
	$filename=getGP('filename','P');
	$enddate=getGP('enddate','P');
	$position=getGP('position','P');
	$page=getGP('page','P');
	$appendix=getGP('file1','P').",".getGP('file2','P').",".getGP('file3','P');
	$content=getGP('content','P');
	$file = array(
		'filetype' => $filetype,
		'filenumber' => $filenumber,
		'filename' => $filename,
		'enddate' => $enddate,
		'position' => $position,
		'page' => $page,
		'appendix' => $appendix,
		'content' => $content
	);
	update_db('file',$file, array('id' => $id));
	$content=$filetype.get_inc_log(1).$filenumber.get_inc_log(1).$filename.get_inc_log(1).$enddate.get_inc_log(1).$position.get_inc_log(1).$page.get_inc_log(1).$appendix.get_inc_log(1).$content;
	$title='编辑档案信息';
	get_oa_log_dbadd($id,$content,$title,20,$_USER->id);
    goto_page('admin.php?ac=index&fileurl=file');

}

//读取部门
function GET_FILE_PUBLIC_LIST($fatherid=0,$selid=0,$layer=0)
{


	$str=""; 
    global $db;
	$query = $db->query("SELECT * FROM ".DB_TABLEPRE."file_type where father='$fatherid' ORDER BY id Asc  ");
	
	if(count($query)>0){
	   for($i=0;$i<$layer;$i++){
	   
	   $str.="├";
	   
	   }
	while ($row = $db->fetch_array($query)) {
	$selstr = $row['id'] == $selid ? 'selected="selected"' : '';
	
	$htmlstr= '<option value="'.$row['id'].'"  '.$selstr.'>'.$str.$row['title'].'</option>';
	
	echo $htmlstr;

	GET_FILE_PUBLIC_LIST($row['id'],$selid,$layer+1,$type);
	
	}

	}
	
   return ;

}

?>